package com.javaweb.controller;

/**
 * @desc:
 * @author: Ping
 * @date: 2024/10/22 23:01
 */

import com.javaweb.controller.common.ResponseResult;
import com.javaweb.model.Category;
import com.javaweb.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * todo: 分类管理模块
 */
@RestController
@RequestMapping("/blog-api/v0.1/category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @PostMapping("/add")
    public ResponseResult add(@RequestBody Category category){
        return ResponseResult.ok(categoryService.add(category),"添加成功");
    }

    @GetMapping("/delete")
    public ResponseResult delete(Integer categoryId){
        return ResponseResult.ok(categoryService.delete(categoryId),"删除成功");
    }

    @GetMapping("/list")
    public ResponseResult<List<Category>> list(){
        return ResponseResult.ok(categoryService.list());
    }


}
